package com.huluobo.a2208parkdemo.parking

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/12/19.
 */
@HiltViewModel
class ParkingViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getAllParkingSuccess by lazy { MutableLiveData<String>() }
    fun getAllParking() {
        executeNetwork(
            { apiService.getAllParking() },
            getAllParkingSuccess::postValue
        )
    }

    val deleteParkingSuccess by lazy { MutableLiveData<String>() }
    fun deleteParking(body: RequestBody) {
        executeNetwork(
            { apiService.deleteParking(body) },
            deleteParkingSuccess::postValue
        )
    }

    val getCarColorsSuccess by lazy { MutableLiveData<String>() }
    fun getCarColor() {
        executeNetwork(
            { apiService.getCarColor() },
            getCarColorsSuccess::postValue
        )
    }

    val addParkingSuccess by lazy { MutableLiveData<String>() }
    fun addParking(body: RequestBody) {
        executeNetwork(
            { apiService.addParking(body) },
            addParkingSuccess::postValue
        )
    }
}